<?php 

Class ModuleFilters extends CmsModule {
	private $selected_month = 0;
	private $selected_day = 0;
	private $selected_year = 0;
	private $year_start = 2007;
	private $monthdays = array(31, 28, 31,30,31,30,31,31,30,31,30,31);
	private $types = array('All','Preminum','Free');
	private $ages = array('All','0-15岁','15-20岁','20-30岁');
	private $genders = array('All','Male','Female');
	private $countrys = array('All','HongKong','China','Tw');
	private $bitrates = array('All','200k','500k','1.5M');
	private $categorys = array('All','Jade','J8','J2');
	
	public function __construct(){
		$this->selected_month = isset($_REQUEST['month']) ? $_REQUEST['month'] : date('n');
		$this->selected_day = isset($_REQUEST['day']) ? $_REQUEST['day'] : date('j');
		$this->selected_year = isset($_REQUEST['year']) ? $_REQUEST['year'] : date('Y');
		$this->selected_age = isset($_REQUEST['age']) ? $_REQUEST['age'] : 0;
		$this->selected_gender = isset($_REQUEST['gender']) ? $_REQUEST['gender'] : 0;
		$this->selected_country = isset($_REQUEST['country']) ? $_REQUEST['country'] : 0;
		$this->selected_bitrate = isset($_REQUEST['bitrate']) ? $_REQUEST['bitrate'] : 0;
		$this->selected_category = isset($_REQUEST['category']) ? $_REQUEST['category'] : 0;
		$this->selected_type = isset($_REQUEST['type']) ? $_REQUEST['type'] : 0;
		$this->selected_action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'month';
	}
    protected function __init()
    {
		
        $this->initTarget['actionvalue'] = $this->selected_action;
		$tmp = array();
		for($i=1; $i<13; $i++){
			$tmp[] = "<option value=\"{$i}\"".($this->selected_month == $i ? ' selected=\"selected\"': '').">{$i}</option>";
		}
        $this->initTarget['moptions'] = implode('', $tmp);
        $this->initTarget['monthinfo'] = $this->selected_month;
		
		$tmp = array();
		for($i=1; $i<$this->monthdays[$this->selected_month-1]+1; $i++){
			$tmp[] = "<option value=\"{$i}\"".($this->selected_day == $i ? ' selected=\"selected\"': '').">{$i}</option>";
		}
        $this->initTarget['dayoptions'] = implode('', $tmp);
        $this->initTarget['dayinfo'] = $this->selected_day;
		
		$tmp = array();
		for($i=$this->year_start; $i< (int)date("Y")+1; $i++){
			$tmp[] = "<option value=\"{$i}\"".($this->selected_year == $i ? ' selected=\"selected\"': '').">{$i}</option>";
		}
        $this->initTarget['yearoptions'] = implode('', $tmp);
        $this->initTarget['yearinfo'] = $this->selected_year;
		
		$tmp = array();
		for($i=0; $i< 3; $i++){
			$tmp[] = "<option value=\"{$i}\"".($this->selected_age == $i ? ' selected=\"selected\"': '').">{$this->ages[$i]}</option>";
		}
        $this->initTarget['ageoptions'] = implode('', $tmp);
        $this->initTarget['ageinfo'] = $this->ages[$this->selected_age];
		
		$tmp = array();
		for($i=0; $i< 3; $i++){
			$tmp[] = "<option value=\"{$i}\"".($this->selected_gender == $i ? ' selected=\"selected\"': '').">{$this->genders[$i]}</option>";
		}
        $this->initTarget['genderoptions'] = implode('', $tmp);
		$this->initTarget['genderinfo'] = $this->genders[$this->selected_gender];
		
		$tmp = array();
		for($i=0; $i< 3; $i++){
			$tmp[] = "<option value=\"{$i}\"".($this->selected_country == $i ? ' selected=\"selected\"': '').">{$this->countrys[$i]}</option>";
		}
        $this->initTarget['countryoptions'] = implode('', $tmp);
		$this->initTarget['countryinfo'] = $this->countrys[$this->selected_country];
		
		$tmp = array();
		for($i=0; $i< 3; $i++){
			$tmp[] = "<option value=\"{$i}\"".($this->selected_bitrate == $i ? ' selected=\"selected\"': '').">{$this->bitrates[$i]}</option>";
		}
        $this->initTarget['bitrateoptions'] = implode('', $tmp);
		$this->initTarget['bitrateinfo'] = $this->bitrates[$this->selected_bitrate];
		
		$tmp = array();
		for($i=0; $i< 3; $i++){
			$tmp[] = "<option value=\"{$i}\"".($this->selected_category == $i ? ' selected=\"selected\"': '').">{$this->categorys[$i]}</option>";
		}
        $this->initTarget['categoryoptions'] = implode('', $tmp);
		$this->initTarget['categoryinfo'] = $this->categorys[$this->selected_category];
		
		$tmp = array();
		for($i=0; $i< 3; $i++){
			$tmp[] = "<option value=\"{$i}\"".($this->selected_type == $i ? ' selected=\"selected\"': '').">{$this->types[$i]}</option>";
		}
        $this->initTarget['typeoptions'] = implode('', $tmp);
		$this->initTarget['typeinfo'] = $this->types[$this->selected_type];
    }
}
?>